package com.homeWork04;

public class Customer extends Thread {
    @Override
    public void run() {
        while (true) {
            synchronized (Box.lock) {
                if (Box.numberOfBottles == 0) {
                    break;
                }
                if (Box.flog) {
                    System.out.println("消费者喝了一瓶奶");
                    Box.flog = false;
                    Box.numberOfBottles--;
                    Box.lock.notifyAll();
                } else {
                    try {
                        Box.lock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
